package com.taiyuan.zfmvp.JUC.ThreadPool;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * @param
 * @Author: zhoufang@si-tech.com.cn
 * @Descriiption:
 * @Date 2022/10/7
 * @return
 */
public class ThreadPoolDemo {

    public static void main(String[] args) {
        //多个线程
        ExecutorService pool = Executors.newFixedThreadPool(5);
        //单个线程
        ExecutorService pool2 = Executors.newSingleThreadExecutor();
        //一池可扩容线程
        //ExecutorService pool3 = Executors.newCachedThreadPool();
        try {
            for (int i = 0; i < 10; i++) {

                pool.execute(new Runnable() {
                    @Override
                    public void run() {
                        System.out.println(Thread.currentThread().getName()+" 办理业务");
                    }
                });

            }
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            pool.shutdown();
        }






    }

}
